﻿@model MVCApp.Models.Person

@{
    int districtId = @ViewBag.DistrictId; 
}

<tr data-personId="@Model.Id">
    <td>
        @if(!String.IsNullOrEmpty(ViewBag.PersonCounter.ToString())) 
        {
            @ViewBag.PersonCounter@:.
        }
    </td>
            
    <td>
        @Html.DisplayFor(modelItem => Model.Name)
    </td>
    <td>
        @Html.DisplayFor(modelItem => Model.Lastname)
    </td>
    <td>
        @Html.DisplayFor(modelItem => Model.StreetAddress)
    </td>
    @if(ViewBag.IsMultiPostCode)
    {
    <td>
        @Html.DisplayFor(modelItem => Model.PostCode)
    </td>
    }
    <td>
        @Html.DisplayFor(modelItem => Model.TelephoneNumber)
    </td>
    <td style="max-width:200px">
        @Html.DisplayFor(modelItem => Model.Remarks)
    </td>
    <td >
        <span data-type="PersonEditButtons" 
			@if(ViewBag.ShowEditButtons == null || !ViewBag.ShowEditButtons){ 
				@: style="display:none"
			}
			>
        @Ajax.ActionLink("Usuń", "DeletePerson", 
            new { personId = @Model.Id, districtId = districtId}, 
            new AjaxOptions 
            { 
                HttpMethod = "post",
                Confirm = @String.Format(@Strings.PersonDeleteConfirmation, Model.Name, Model.Lastname, Model.StreetAddress),
                OnSuccess = "personDeleted",
                OnFailure = "personDeleteError"                
            })
            |
            @Html.ActionLink("Edytuj", "EditPerson", new { id=@Model.Id })
        </span>
    </td>
</tr>